package com.legendshop.openportal.sdk.utils.decryptor;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;

/**
 * rsa 解密器
 * @author chan
 */
public class RsaContentDecryptor implements ContentDecryptor {

    /**
     * 私钥
     */
    private final RSA rsa;

    public RsaContentDecryptor(String privateKey) {
        this.rsa = SecureUtil.rsa(privateKey, null);
    }

    @Override
    public String decrypt(String encryptMessage) {
        return this.rsa.decryptStr(encryptMessage, KeyType.PrivateKey);
    }

}
